//
//  APLets.swift
//  APExtensions
//
//  Created by jianbo.pei on 2023/6/25.
//

import Foundation
import UIKit

public let ap_kScreenW = UIScreen.main.bounds.width
public let ap_kScreenH = UIScreen.main.bounds.height

/// 获取状态栏高度
/// [原文链接](https://blog.csdn.net/u014651417/article/details/123423893)
public var ap_kStatusHeight: CGFloat {
    get {
        if #available(iOS 13.0, *) {
            let keyWindow = UIApplication.shared.connectedScenes
                .map({ $0 as? UIWindowScene })
                .compactMap({ $0 })
                .first?.windows.first
            let statusBar = keyWindow?.windowScene?.statusBarManager?.statusBarFrame
            return statusBar?.size.height ?? 20.0
        } else {
            return UIApplication.shared.statusBarFrame.size.height
        }
    }
}


